package com.flrjcx.controller;

import com.flrjcx.common.model.UserModel;
import com.flrjcx.common.model.result.ResponseData;
import com.flrjcx.service.RegisterService;
import com.flrjcx.common.utils.EmailSendUtils;
import com.flrjcx.common.utils.ValidateCodeUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
/**
 * 用户注册控制器
 * @author Flrjcx
 */

@Api("用户注册")
@ApiRestController("zlHouse")
@Slf4j
public class RegisterController {
    @Autowired
    private EmailSendUtils emailSendUtils;
    @Resource
    private RegisterService registerService;
    @PostMapping("/register")
    public ResponseData register(@RequestBody UserModel userModel){
        ResponseData result = registerService.verifyRegisterBeforeAll(userModel);
        return result;
    }
    @GetMapping("/getValidateCode")
    public Integer validateCode(){
        Integer validateCode = ValidateCodeUtils.generateValidateCode(6);
        emailSendUtils.sendFixedMail("872485330@qq.com",validateCode,"flrjcx");
        /**
         * 校验
         * 跳转
         * session
         * html邮箱
         * 待做 08.17
         */
        return validateCode;
    }


}
